package com.example.javamaday.thread;

public class InterruptThread {

    public static void main(String[] args) throws InterruptedException {
        InterruptableThread interruptableThread = new InterruptableThread();
        interruptableThread.start();
        Thread.sleep(6);
        interruptableThread.interrupt();
    }


    static class InterruptableThread extends Thread {

        public volatile boolean isStopped = false;

        @Override
        public void run() {
            super.run();
            for (int i = 0; i < 10000000 ; i++) {
                if (interrupted()) {
                    System.out.println("i = " + i);
                    return;
                }
            }
        }
    }
}
